using System;
using UnityEngine;

namespace NodeCanvas.Variables
{
	[Serializable]
	public class BBEnum : BBVariable, IMultiCastable
	{
		[SerializeField]
		private string _value;

		[SerializeField]
		private string _typeName = typeof(Enum).AssemblyQualifiedName;

		public Enum value
		{
			get
			{
				return (!base.useBlackboard) ? ((Enum)Enum.Parse(type, _value)) : Read<Enum>();
			}
			set
			{
				if (base.useBlackboard)
				{
					Write(value);
				}
				else
				{
					_value = Enum.GetName(type, value);
				}
			}
		}

		public override Type varType
		{
			get
			{
				return type;
			}
		}

		public Type baseType
		{
			get
			{
				return typeof(Enum);
			}
		}

		public Type type
		{
			get
			{
				return Type.GetType(_typeName);
			}
			set
			{
				_typeName = value.AssemblyQualifiedName;
				_value = Enum.GetNames(value)[0];
			}
		}
	}
}
